package com.ruoyi.web.controller.invoice;

import com.ruoyi.dto.JqbhDto;
import com.ruoyi.dto.NsrshbDto;
import com.ruoyi.third.base.InvoiceApiResult;
import com.ruoyi.third.entity.request.BillUnitAdd;
import com.ruoyi.third.entity.request.BillUnitEdit;
import com.ruoyi.third.entity.request.BillUnitSearch;
import com.ruoyi.third.service.ThirdApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "开票单位")
@RestController
@AllArgsConstructor
@RequestMapping("invoice/billUnit")
public class BillUnitController {

    private final ThirdApiService thirdApiService;

    @ApiOperation(value = "开票单位查询", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "BillUnitSearch", value = "BillUnitSearch", dataTypeClass = BillUnitSearch.class)
    })
    @PostMapping("billUnitSearch")
    public InvoiceApiResult billUnitSearch(@RequestBody @Validated BillUnitSearch billUnitSearch) {
        return thirdApiService.billUnitSearch(billUnitSearch);
    }

    @ApiOperation(value = "开票单位新增", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "BillUnitAdd", value = "BillUnitAdd", dataTypeClass = BillUnitAdd.class)
    })
    @PostMapping("billUnitAdd")
    public InvoiceApiResult billUnitAdd(@RequestBody @Validated BillUnitAdd param) {
        return thirdApiService.billUnitAdd(param);
    }

    @ApiOperation(value = "开票单位修改", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "BillUnitEdit", value = "BillUnitEdit", dataTypeClass = BillUnitEdit.class)
    })
    @PostMapping("billUnitEdit")
    public InvoiceApiResult billUnitEdit(@RequestBody @Validated BillUnitEdit param) {
        return thirdApiService.billUnitEdit(param);
    }

    @ApiOperation(value = "开票单位删除", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nsrsbh", value = "纳税人识别号", dataTypeClass = String.class)
    })
    @PostMapping("billUnitDel")
    public InvoiceApiResult billUnitDel(@RequestBody @Validated NsrshbDto param) {
        return thirdApiService.billUnitDel(param.getNsrsbh());
    }


    @ApiOperation(value = "查询开票单位信息 id 接口", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jqbh", value = "机器编号", dataTypeClass = String.class)
    })
    @PostMapping("searchKphxxById")
    public InvoiceApiResult searchKphxxById(@RequestBody @Validated JqbhDto param) {
        return thirdApiService.searchKphxxById(param.getJqbh());
    }


}
